﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace Pharmacy_management_system
{
    public partial class dcb : Form
    {
        public dcb()
        {
            InitializeComponent();
        }
        int j = 0;
        private void method()
        {
            try
            {
                using (SqlConnection conn1 = new SqlConnection(SQL.constr))
                {
                    conn1.Open();
                    SqlDataAdapter da1 = new SqlDataAdapter("select kjm from table_ak where inp_no= '" + Form1.blh + "'", conn1);
                    DataTable dt1 = new DataTable();
                    da1.Fill(dt1);
                    if (dt1.Rows.Count > 0)
                        foreach (Control c in this.panel1.Controls)
                        {

                            if (c.GetType().Name == "CheckBox")//&& c.Name == "cgjy_xcg"
                            {
                                for (int i = 0; i < dt1.Rows.Count; i++)
                                {
                                    if (c.Name == dt1.Rows[i][0].ToString())
                                    {
                                        ((CheckBox)c).Checked = true;
                                        //((CheckBox)c).Enabled = false;
                                    }
                                    //else
                                    //{
                                    //    ((CheckBox)c).Checked = false;
                                    //    ((CheckBox)c).Enabled = true;
                                    //}
                                }

                            }
                        }

                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
        private void method2()
        {
            try
            {
                using (SqlConnection conn1 = new SqlConnection(SQL.constr))
                {
                    int k = 0;
                    conn1.Open();
                    SqlDataAdapter da1 = new SqlDataAdapter("select kjm from table_ak where inp_no= '" + Form1.blh + "'", conn1);
                    DataTable dt1 = new DataTable();
                    da1.Fill(dt1);
                    if (dt1.Rows.Count > 0)
                        foreach (Control c in this.panel1.Controls)
                        {

                            if (c.GetType().Name == "CheckBox")//&& c.Name == "cgjy_xcg"
                            {
                                for (int i = 0; i < dt1.Rows.Count; i++)
                                {
                                    if (c.Name == dt1.Rows[i][0].ToString())
                                    {
                                        //((CheckBox)c).Checked = true;
                                        if (((CheckBox)c).Checked)
                                        {
                                            continue;
                                        }
                                        else
                                        {
                                            SqlCommand cmd1 = new SqlCommand("delete from table_ak where kjm='" + c.Name + "'", conn1);
                                            k = cmd1.ExecuteNonQuery();
                                        }

                                        //((CheckBox)c).Enabled = false;
                                    }
                                    //else
                                    //{
                                    //    ((CheckBox)c).Checked = false;
                                    //    ((CheckBox)c).Enabled = true;
                                    //}
                                }

                            }
                        }
                    if (k > 0)
                    {
                      
                    }

                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }





        public string xb="",nl="",tz="",rysj = "",cysj="",shmc="",qklx="",rysj1="",cysj1="",blh="",cyzd="",ssks01;
        #region 调查表2load事件
        private void DiaoChaBiao2_Load(object sender, EventArgs e)
        {
            this.MouseWheel += new MouseEventHandler(FormSample_MouseWheel); //注册下拉事件
            
            
            dataGridView1.Visible = false;
            textBox4.Text = xb;
            textBox24.Text = nl;
            textBox25.Text = tz;
            textBox26.Text = rysj;
            textBox53.Text = cysj;
            label85.Text = shmc;
            label224.Text = qklx;
            label225.Text = rysj1;
            label226.Text = cysj1;
            textBox5.Text = blh;
            textBox2.Text = blh;
            textBox11.Text = cyzd;
            textBox55.Text = ssks01;
            method();
            //label232.Text = Form1.dept01;
            string strsql = "select inp_no,fei3,tiwen1,wbc1,neut1,alt1,cr1,tiwen2,wbc2,neut2,alt2,cr2,biaoben,ganran,x1,x2,jf_ganran,ywxz_1,ywxz_2,dcjl_1,dcjl_2,pc_1,pc_2,rj_1,rj_2,yy_1,yy_2,shuqian_1,shuqian_2,shuzhong_1,shuzhong_2,shuhou_1,shuhou_2,beizhu from diaochabiao_1 where inp_no='" + Form1.blh + "'";
            SqlConnection conn = new SqlConnection(SQL.constr);
            conn.Open();
            SqlDataAdapter hhh = new SqlDataAdapter(strsql, SQL.constr);
            DataSet dtt = new DataSet();
            hhh.Fill(dtt);
            for (int i = 0; i < dtt.Tables[0].Rows.Count; i++)
            {
                textBox5.Text = dtt.Tables[0].Rows[i].ItemArray[0].ToString();//住院
                textBox12.Text = dtt.Tables[0].Rows[i].ItemArray[1].ToString();//病人名
                 textBox13.Text = dtt.Tables[0].Rows[i].ItemArray[2].ToString();//性别
                textBox14.Text  = dtt.Tables[0].Rows[i].ItemArray[3].ToString();//出生日期
                textBox15.Text = dtt.Tables[0].Rows[i].ItemArray[4].ToString();//年龄
                textBox16.Text = dtt.Tables[0].Rows[i].ItemArray[5].ToString();//身高
                textBox17.Text = dtt.Tables[0].Rows[i].ItemArray[6].ToString();//体重
                textBox22.Text = dtt.Tables[0].Rows[i].ItemArray[7].ToString();//身份证
                textBox21.Text = dtt.Tables[0].Rows[i].ItemArray[8].ToString();//民族
                textBox20.Text = dtt.Tables[0].Rows[i].ItemArray[9].ToString();//籍贯
                textBox19.Text = dtt.Tables[0].Rows[i].ItemArray[10].ToString();//工作单位
                 textBox18.Text= dtt.Tables[0].Rows[i].ItemArray[11].ToString();//联系地址
                 textBox23.Text= dtt.Tables[0].Rows[i].ItemArray[12].ToString();//联系电话
                textBox27.Text = dtt.Tables[0].Rows[i].ItemArray[13].ToString();//入院日期
                textBox28.Text = dtt.Tables[0].Rows[i].ItemArray[14].ToString();//出院日期
               textBox29.Text = dtt.Tables[0].Rows[i].ItemArray[15].ToString();//科室
                 textBox33.Text= dtt.Tables[0].Rows[i].ItemArray[16].ToString();//床号
                 textBox34.Text= dtt.Tables[0].Rows[i].ItemArray[17].ToString();//医生
                 textBox35.Text= dtt.Tables[0].Rows[i].ItemArray[18].ToString();//入院诊断
                textBox36.Text = dtt.Tables[0].Rows[i].ItemArray[19].ToString();//出院诊断
                 textBox37.Text= dtt.Tables[0].Rows[i].ItemArray[20].ToString();//过敏历
                textBox38.Text= dtt.Tables[0].Rows[i].ItemArray[21].ToString();//护理级别
                textBox39.Text = dtt.Tables[0].Rows[i].ItemArray[22].ToString();//费用类别
               textBox40.Text = dtt.Tables[0].Rows[i].ItemArray[23].ToString();//费用类别
                textBox41.Text= dtt.Tables[0].Rows[i].ItemArray[24].ToString();//费用类别
                textBox44.Text= dtt.Tables[0].Rows[i].ItemArray[25].ToString();//费用类别
               textBox45.Text = dtt.Tables[0].Rows[i].ItemArray[26].ToString();//费用类别
               textBox46.Text = dtt.Tables[0].Rows[i].ItemArray[27].ToString();//费用类别
               textBox47.Text = dtt.Tables[0].Rows[i].ItemArray[28].ToString();//费用类别
                textBox48.Text= dtt.Tables[0].Rows[i].ItemArray[29].ToString();//费用类别
                textBox49.Text= dtt.Tables[0].Rows[i].ItemArray[30].ToString();//费用类别
                textBox50.Text = dtt.Tables[0].Rows[i].ItemArray[31].ToString();//费用类别
                 textBox51.Text= dtt.Tables[0].Rows[i].ItemArray[32].ToString();//费用类别
                textBox52.Text= dtt.Tables[0].Rows[i].ItemArray[33].ToString();//费用类别
                
            }
            conn.Close();
           
               
           


        }

        void FormSample_MouseWheel(object sender, MouseEventArgs e)
        {
            //获取光标位置 
            Point mousePoint = new Point(e.X, e.Y);
            //换算成相对本窗体的位置 
            mousePoint.Offset(this.Location.X, this.Location.Y);
            //判断是否在panel内 
            if (panel1.RectangleToScreen(panel1.DisplayRectangle).Contains(mousePoint))
            {
                //滚动 
                panel1.AutoScrollPosition = new Point(0, panel1.VerticalScroll.Value - e.Delta);
            }
        }
       


        #endregion
        private void xuanding(string kjm, string kjwb)
        {
            try
            {
                j = this.dataGridView1.Rows.Count;


                this.dataGridView1.Rows.Add();
                this.dataGridView1.Rows[j].Cells[0].Value = textBox5.Text;
                this.dataGridView1.Rows[j].Cells[1].Value = kjm;
                this.dataGridView1.Rows[j].Cells[2].Value = kjwb;


                j++;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }

        }
        private void shanchu(string kjm, string kjwb)
        {
            try
            {
                for (int i = 0; i < dataGridView1.Rows.Count; i++)
                {
                    if (this.dataGridView1.Rows[i].Cells[1].Value.ToString() == kjm)
                    {
                        this.dataGridView1.Rows.RemoveAt(i);
                        j--;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }

        }
        #region  事件
        private void checkBox4_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox4.Checked)
            {
                xuanding(this.checkBox4.Name, this.checkBox4.Text);

            }
            else
            {
                shanchu(this.checkBox4.Name, this.checkBox4.Text);

            }
        }

        private void checkBox5_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox5.Checked)
            {
                xuanding(this.checkBox5.Name, this.checkBox5.Text);

            }
            else
            {
                shanchu(this.checkBox5.Name, this.checkBox5.Text);

            }
        }

        private void checkBox6_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox6.Checked)
            {
                xuanding(this.checkBox6.Name, this.checkBox5.Text);

            }
            else
            {
                shanchu(this.checkBox6.Name, this.checkBox6.Text);

            }
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox1.Checked)
            {
                xuanding(this.checkBox1.Name, this.checkBox1.Text);

            }
            else
            {
                shanchu(this.checkBox1.Name, this.checkBox1.Text);

            }
        }

        private void checkBox3_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox3.Checked)
            {
                xuanding(this.checkBox3.Name, this.checkBox3.Text);

            }
            else
            {
                shanchu(this.checkBox3.Name, this.checkBox3.Text);

            }
        }

        private void checkBox2_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox2.Checked)
            {
                xuanding(this.checkBox2.Name, this.checkBox2.Text);

            }
            else
            {
                shanchu(this.checkBox2.Name, this.checkBox2.Text);

            }
        }

        private void checkBox60_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox60.Checked)
            {
                xuanding(this.checkBox60.Name, this.checkBox60.Text);

            }
            else
            {
                shanchu(this.checkBox60.Name, this.checkBox60.Text);

            }
        }

        private void checkBox61_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox61.Checked)
            {
                xuanding(this.checkBox61.Name, this.checkBox61.Text);

            }
            else
            {
                shanchu(this.checkBox61.Name, this.checkBox61.Text);

            }
        }

        private void checkBox62_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox62.Checked)
            {
                xuanding(this.checkBox62.Name, this.checkBox62.Text);

            }
            else
            {
                shanchu(this.checkBox62.Name, this.checkBox62.Text);

            }
        }

        private void checkBox63_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void checkBox63_CheckedChanged_1(object sender, EventArgs e)
        {
            if (this.checkBox63.Checked)
            {
                xuanding(this.checkBox63.Name, this.checkBox63.Text);

            }
            else
            {
                shanchu(this.checkBox63.Name, this.checkBox63.Text);

            }
        }

        private void checkBox7_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox7.Checked)
            {
                xuanding(this.checkBox7.Name, this.checkBox7.Text);

            }
            else
            {
                shanchu(this.checkBox7.Name, this.checkBox7.Text);

            }
        }

        private void checkBox8_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox8.Checked)
            {
                xuanding(this.checkBox8.Name, this.checkBox8.Text);

            }
            else
            {
                shanchu(this.checkBox8.Name, this.checkBox8.Text);

            }
        }

        private void checkBox9_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox9.Checked)
            {
                xuanding(this.checkBox9.Name, this.checkBox9.Text);

            }
            else
            {
                shanchu(this.checkBox9.Name, this.checkBox9.Text);

            }
        }

        private void checkBox10_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox10.Checked)
            {
                xuanding(this.checkBox10.Name, this.checkBox10.Text);

            }
            else
            {
                shanchu(this.checkBox10.Name, this.checkBox10.Text);

            }
        }

        private void checkBox11_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox11.Checked)
            {
                xuanding(this.checkBox11.Name, this.checkBox11.Text);

            }
            else
            {
                shanchu(this.checkBox11.Name, this.checkBox11.Text);

            }
        }

        private void checkBox12_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox12.Checked)
            {
                xuanding(this.checkBox12.Name, this.checkBox12.Text);

            }
            else
            {
                shanchu(this.checkBox12.Name, this.checkBox12.Text);

            }
        }

        private void checkBox13_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox13.Checked)
            {
                xuanding(this.checkBox13.Name, this.checkBox13.Text);

            }
            else
            {
                shanchu(this.checkBox13.Name, this.checkBox13.Text);

            }
        }

        private void checkBox16_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox16.Checked)
            {
                xuanding(this.checkBox16.Name, this.checkBox16.Text);

            }
            else
            {
                shanchu(this.checkBox16.Name, this.checkBox16.Text);

            }
        }

        private void checkBox17_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox17.Checked)
            {
                xuanding(this.checkBox17.Name, this.checkBox17.Text);

            }
            else
            {
                shanchu(this.checkBox17.Name, this.checkBox17.Text);

            }
        }

        private void checkBox18_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox18.Checked)
            {
                xuanding(this.checkBox18.Name, this.checkBox18.Text);

            }
            else
            {
                shanchu(this.checkBox18.Name, this.checkBox18.Text);

            }
        }

        private void checkBox19_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox19.Checked)
            {
                xuanding(this.checkBox19.Name, this.checkBox19.Text);

            }
            else
            {
                shanchu(this.checkBox19.Name, this.checkBox19.Text);

            }
        }

        private void checkBox20_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox20.Checked)
            {
                xuanding(this.checkBox20.Name, this.checkBox20.Text);

            }
            else
            {
                shanchu(this.checkBox20.Name, this.checkBox20.Text);

            }
        }

        private void checkBox21_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox21.Checked)
            {
                xuanding(this.checkBox21.Name, this.checkBox21.Text);

            }
            else
            {
                shanchu(this.checkBox21.Name, this.checkBox21.Text);

            }
        }

        private void checkBox22_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox22.Checked)
            {
                xuanding(this.checkBox22.Name, this.checkBox22.Text);

            }
            else
            {
                shanchu(this.checkBox22.Name, this.checkBox22.Text);

            }
        }

        private void checkBox23_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox23.Checked)
            {
                xuanding(this.checkBox23.Name, this.checkBox23.Text);

            }
            else
            {
                shanchu(this.checkBox23.Name, this.checkBox23.Text);

            }
        }

        private void checkBox24_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox24.Checked)
            {
                xuanding(this.checkBox24.Name, this.checkBox24.Text);

            }
            else
            {
                shanchu(this.checkBox24.Name, this.checkBox24.Text);

            }
        }

        private void checkBox25_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox25.Checked)
            {
                xuanding(this.checkBox25.Name, this.checkBox25.Text);

            }
            else
            {
                shanchu(this.checkBox25.Name, this.checkBox25.Text);

            }
        }

        private void checkBox26_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox26.Checked)
            {
                xuanding(this.checkBox26.Name, this.checkBox26.Text);

            }
            else
            {
                shanchu(this.checkBox26.Name, this.checkBox26.Text);

            }
        }

        private void checkBox28_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox28.Checked)
            {
                xuanding(this.checkBox28.Name, this.checkBox28.Text);

            }
            else
            {
                shanchu(this.checkBox28.Name, this.checkBox28.Text);

            }
        }

        private void checkBox27_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox27.Checked)
            {
                xuanding(this.checkBox27.Name, this.checkBox27.Text);

            }
            else
            {
                shanchu(this.checkBox27.Name, this.checkBox27.Text);

            }
        }

        private void checkBox29_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox29.Checked)
            {
                xuanding(this.checkBox29.Name, this.checkBox29.Text);

            }
            else
            {
                shanchu(this.checkBox29.Name, this.checkBox29.Text);

            }
        }

        private void checkBox30_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox30.Checked)
            {
                xuanding(this.checkBox30.Name, this.checkBox30.Text);

            }
            else
            {
                shanchu(this.checkBox30.Name, this.checkBox30.Text);

            }
        }

        private void checkBox31_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox31.Checked)
            {
                xuanding(this.checkBox31.Name, this.checkBox31.Text);

            }
            else
            {
                shanchu(this.checkBox31.Name, this.checkBox31.Text);

            }
        }

        private void checkBox32_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox32.Checked)
            {
                xuanding(this.checkBox32.Name, this.checkBox32.Text);

            }
            else
            {
                shanchu(this.checkBox32.Name, this.checkBox32.Text);

            }
        }

        private void checkBox34_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox34.Checked)
            {
                xuanding(this.checkBox34.Name, this.checkBox34.Text);

            }
            else
            {
                shanchu(this.checkBox34.Name, this.checkBox34.Text);

            }
        }

        private void checkBox33_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox33.Checked)
            {
                xuanding(this.checkBox33.Name, this.checkBox33.Text);

            }
            else
            {
                shanchu(this.checkBox33.Name, this.checkBox33.Text);

            }
        }

        private void checkBox35_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox35.Checked)
            {
                xuanding(this.checkBox35.Name, this.checkBox35.Text);

            }
            else
            {
                shanchu(this.checkBox35.Name, this.checkBox35.Text);

            }
        }

        private void checkBox36_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox36.Checked)
            {
                xuanding(this.checkBox36.Name, this.checkBox36.Text);

            }
            else
            {
                shanchu(this.checkBox36.Name, this.checkBox36.Text);

            }
        }

        private void checkBox40_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox40.Checked)
            {
                xuanding(this.checkBox40.Name, this.checkBox40.Text);

            }
            else
            {
                shanchu(this.checkBox40.Name, this.checkBox40.Text);

            }
        }

        private void checkBox41_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox41.Checked)
            {
                xuanding(this.checkBox41.Name, this.checkBox41.Text);

            }
            else
            {
                shanchu(this.checkBox41.Name, this.checkBox41.Text);

            }
        }

        private void checkBox42_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox42.Checked)
            {
                xuanding(this.checkBox42.Name, this.checkBox42.Text);

            }
            else
            {
                shanchu(this.checkBox42.Name, this.checkBox42.Text);

            }
        }

        private void checkBox43_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox43.Checked)
            {
                xuanding(this.checkBox43.Name, this.checkBox43.Text);

            }
            else
            {
                shanchu(this.checkBox43.Name, this.checkBox43.Text);

            }
        }

        private void checkBox44_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox44.Checked)
            {
                xuanding(this.checkBox44.Name, this.checkBox44.Text);

            }
            else
            {
                shanchu(this.checkBox44.Name, this.checkBox44.Text);

            }
        }

        private void checkBox49_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox49.Checked)
            {
                xuanding(this.checkBox49.Name, this.checkBox49.Text);

            }
            else
            {
                shanchu(this.checkBox49.Name, this.checkBox49.Text);

            }
        }

        private void checkBox48_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox48.Checked)
            {
                xuanding(this.checkBox48.Name, this.checkBox48.Text);

            }
            else
            {
                shanchu(this.checkBox48.Name, this.checkBox48.Text);

            }
        }

        private void checkBox47_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox47.Checked)
            {
                xuanding(this.checkBox47.Name, this.checkBox47.Text);

            }
            else
            {
                shanchu(this.checkBox47.Name, this.checkBox47.Text);

            }
        }

        private void checkBox46_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox46.Checked)
            {
                xuanding(this.checkBox46.Name, this.checkBox46.Text);

            }
            else
            {
                shanchu(this.checkBox46.Name, this.checkBox46.Text);

            }
        }

        private void checkBox45_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox45.Checked)
            {
                xuanding(this.checkBox45.Name, this.checkBox45.Text);

            }
            else
            {
                shanchu(this.checkBox45.Name, this.checkBox45.Text);

            }
        }

        private void checkBox50_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox50.Checked)
            {
                xuanding(this.checkBox50.Name, this.checkBox50.Text);

            }
            else
            {
                shanchu(this.checkBox50.Name, this.checkBox50.Text);

            }
        }

        private void checkBox51_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox51.Checked)
            {
                xuanding(this.checkBox51.Name, this.checkBox51.Text);

            }
            else
            {
                shanchu(this.checkBox51.Name, this.checkBox51.Text);

            }
        }

        private void checkBox54_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox54.Checked)
            {
                xuanding(this.checkBox54.Name, this.checkBox54.Text);

            }
            else
            {
                shanchu(this.checkBox54.Name, this.checkBox54.Text);

            }
        }

        private void checkBox53_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox53.Checked)
            {
                xuanding(this.checkBox53.Name, this.checkBox53.Text);

            }
            else
            {
                shanchu(this.checkBox53.Name, this.checkBox53.Text);

            }
        }

        private void checkBox52_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox52.Checked)
            {
                xuanding(this.checkBox52.Name, this.checkBox52.Text);

            }
            else
            {
                shanchu(this.checkBox52.Name, this.checkBox52.Text);

            }
        }

        private void checkBox57_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox57.Checked)
            {
                xuanding(this.checkBox57.Name, this.checkBox57.Text);

            }
            else
            {
                shanchu(this.checkBox57.Name, this.checkBox57.Text);

            }
        }

        private void checkBox56_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox56.Checked)
            {
                xuanding(this.checkBox56.Name, this.checkBox56.Text);

            }
            else
            {
                shanchu(this.checkBox56.Name, this.checkBox56.Text);

            }
        }

        private void checkBox55_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox55.Checked)
            {
                xuanding(this.checkBox55.Name, this.checkBox55.Text);

            }
            else
            {
                shanchu(this.checkBox55.Name, this.checkBox55.Text);

            }
        }

        private void checkBox58_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox58.Checked)
            {
                xuanding(this.checkBox58.Name, this.checkBox58.Text);

            }
            else
            {
                shanchu(this.checkBox58.Name, this.checkBox58.Text);

            }
        }

        private void checkBox59_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox59.Checked)
            {
                xuanding(this.checkBox59.Name, this.checkBox59.Text);

            }
            else
            {
                shanchu(this.checkBox59.Name, this.checkBox59.Text);

            }
        }
        #endregion

        private void button1_Click(object sender, EventArgs e)
        {
   
        }

        private void button2_Click(object sender, EventArgs e)
        {
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            method2();
            try
            {
                int bianliang = 0;
                for (int i = 0; i < dataGridView1.Rows.Count; i++)
                {
                    string hh = "insert into table_ak(inp_no,kjm,kjwb) values ('" + dataGridView1.Rows[i].Cells[0].Value.ToString() + "','" + dataGridView1.Rows[i].Cells[1].Value.ToString() + "','" + dataGridView1.Rows[i].Cells[2].Value.ToString() + "') ";
                    using (SqlConnection conn = new SqlConnection(SQL.constr))
                    {
                        conn.Open();
                        SqlCommand cmd = new SqlCommand(hh, conn);
                        bianliang = cmd.ExecuteNonQuery();

                    }
                }
                if (bianliang == 1)
                {
                    MessageBox.Show("修改成功","提示");
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());

            }

            //更新手写输入的字段
            string hh1 = "update diaochabiao_1 set inp_no='" + textBox5.Text + "',fei3='" + textBox12.Text + "',tiwen1='" + textBox13.Text + "',wbc1='" + textBox14.Text + "',neut1='" +
                textBox15.Text + "',alt1='" + textBox16.Text + "',cr1='" + textBox17.Text + "',tiwen2='" + textBox22.Text + "',wbc2='" + textBox21.Text + "',neut2='" + textBox20.Text + "',alt2='" +
                textBox19.Text + "',cr2='" + textBox18.Text + "',biaoben='" + textBox23.Text + "',ganran='" + textBox27.Text + "',x1='" + textBox28.Text + "',x2='" + textBox29.Text + "',jf_ganran='" +
                textBox33.Text + "',ywxz_1='" + textBox34.Text + "',ywxz_2='" + textBox35.Text + "',dcjl_1='" + textBox36.Text + "',dcjl_2='" + textBox37.Text + "',pc_1='" +
                textBox38.Text + "',pc_2='" + textBox39.Text + "',rj_1='" + textBox40.Text + "',rj_2='" + textBox41.Text + "',yy_1='" + textBox44.Text + "',yy_2='" + textBox45.Text + "',shuqian_1='" +
                textBox46.Text + "',shuqian_2='" + textBox47.Text + "',shuzhong_1='" + textBox48.Text + "',shuzhong_2='" + textBox49.Text + "',shuhou_1='" + textBox50.Text + "',shuhou_2='" + textBox51.Text + "',beizhu='" + textBox52.Text + "',tianbiao='" + textBox54.Text + "' ";


            using (SqlConnection conn3 = new SqlConnection(SQL.constr))
            {
                int bianliang3;
                conn3.Open();
                SqlCommand cmd = new SqlCommand(hh1, conn3);
                bianliang3 = cmd.ExecuteNonQuery();

            }
        
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            //checkbox的纪录
            //button1.Enabled = false;
            if (textBox54.Text != "")
            {
                //button1.Enabled = false;
                try
                {
                    int bianliang = 0;
                    for (int i = 0; i < dataGridView1.Rows.Count; i++)
                    {
                        string hh = "insert into table_ak(inp_no,kjm,kjwb) values ('" + dataGridView1.Rows[i].Cells[0].Value.ToString() + "','" + dataGridView1.Rows[i].Cells[1].Value.ToString() + "','" + dataGridView1.Rows[i].Cells[2].Value.ToString() + "') ";
                        using (SqlConnection conn = new SqlConnection(SQL.constr))
                        {
                            conn.Open();
                            SqlCommand cmd = new SqlCommand(hh, conn);
                            bianliang = cmd.ExecuteNonQuery();

                        }
                    }
                    if (bianliang == 1)
                    {
                        MessageBox.Show("保存成功", "提示");
                    }

                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString());

                }
                //更新手写输入的字段
                string hh1 = "insert into diaochabiao_1(inp_no,fei3,tiwen1,wbc1,neut1,alt1,cr1,tiwen2,wbc2,neut2,alt2,cr2,biaoben,ganran,x1,x2,jf_ganran,ywxz_1,ywxz_2,dcjl_1,dcjl_2,pc_1,pc_2,rj_1,rj_2,yy_1,yy_2,shuqian_1,shuqian_2,shuzhong_1,shuzhong_2,shuhou_1,shuhou_2,beizhu,tianbiao) values  ('" +
                    textBox5.Text + "','" + textBox12.Text + "','" + textBox13.Text + "','" + textBox14.Text + "','" + textBox15.Text + "','" + textBox16.Text + "','" + textBox17.Text + "','" +
                    textBox22.Text + "','" + textBox21.Text + "','" + textBox20.Text + "','" + textBox19.Text + "','" + textBox18.Text + "','" + textBox23.Text + "','" + textBox27.Text + "','" + textBox28.Text + "','" + textBox29.Text + "','" +
                    textBox33.Text + "','" + textBox34.Text + "','" + textBox35.Text + "','" + textBox36.Text + "','" + textBox37.Text + "','" + textBox38.Text + "','" + textBox39.Text + "','" +
                    textBox40.Text + "','" + textBox41.Text + "' ,'" + textBox44.Text + "','" + textBox45.Text + "','" + textBox46.Text + "','" + textBox47.Text + "','" + textBox48.Text + "','" + textBox49.Text + "','" + textBox50.Text + "','" + textBox51.Text + "','" + textBox52.Text + "','" + textBox54.Text + "') ";
                using (SqlConnection conn1 = new SqlConnection(SQL.constr))
                {
                    int bianliang1;
                    conn1.Open();
                    SqlCommand cmd = new SqlCommand(hh1, conn1);
                    bianliang1 = cmd.ExecuteNonQuery();

                }
                //if (MessageBox.Show("Delete this user?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                //{
                    //delete
                //}
                    
            }
            if (textBox54.Text == "")
            {
                MessageBox.Show("请输入填表人");
            }
        }

        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
